package myJs.myPkg.reactTransitionGroup

import japgolly.scalajs.react.CtorType.ChildArg
import japgolly.scalajs.react.{Children, JsFnComponent}
import myJs.Implicits.JDJAn
import slinky.readwrite.ObjectOrWritten

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

/** Created by yz on 20/9/2023
  */

@js.native
trait Location extends js.Object {

  val key: String = js.native

  val pathname: String = js.native

  val search: String = js.native

  val state: JDJAn = js.native

}

object CSSTransition {

  @JSImport("react-transition-group", "CSSTransition")
  @js.native
  object RawComponent extends js.Object

  case class Props(
      key: js.UndefOr[String] = js.undefined,
      classNames: String,
      timeout: Int,
      location: js.UndefOr[Location] = js.undefined
  )

  val Component = JsFnComponent[ObjectOrWritten[Props], Children.Varargs](RawComponent)

  def apply(
      key: js.UndefOr[String] = js.undefined,
      classNames: String,
      timeout: Int,
      location: js.UndefOr[Location] = js.undefined
  )(children: ChildArg*) = Component(Props(key, classNames, timeout, location))(children: _*)

}
